using UnityEngine;

public class PlayerStateBehavior_Idle : AbstractPlayerStateBehavior
{
	public static PlayerStateBehavior_Idle instance;

	private PlayerStateBehavior_Idle()
	{
	}

	public static PlayerStateBehavior_Idle getInstance()
	{
		if (instance == null)
		{
			instance = new PlayerStateBehavior_Idle();
		}
		return instance;
	}

	public override void enter(Player owner)
	{
		base.enter(owner);
		owner.playAnimation(AnimationName.player_idle, 0.5f, -1f);
		if (owner.isBallInHand())
		{
			Instance<Ball>.instance.do_rebound();
		}
	}

	public override void fixedUpdate(Player owner)
	{
		base.fixedUpdate(owner);
		if (Instance<Ball>.instance.isInState(BallState_Rebound.getInstance()) && Instance<Ball>.instance.isGetBall(owner.getPosition()))
		{
			Vector3 position = Instance<Ball>.instance.getPosition();
			if (position.y < 1.5f && !Instance<Court>.instance.isInState(CourtStateFreeThrow.getInstance()) && owner.teamType == TeamType.USER)
			{
				Instance<Court>.instance.OnGrabedRebound(owner);
			}
		}
	}
}
